<?php
namespace Home\Controller;

use Home\Model\LoginModel;
use Think\Controller;

/**
 * 首页管理控制器
 * Class IndexController
 * @package Home\Controller
 */
class LoginController extends Controller
{
	protected $db;
	public function __construct()
	{
		parent::__construct();
		$this->db =new LoginModel();
	}

	//注册页面
	public function register ()
	{
		if(IS_POST){
//			p($this->db->reg());die;
//			p($_POST);die;
			if($this->db->reg()){

				$this->success('注册成功',U('home/login/index'),'success');die;
			}else{
				$this->error($this->db->getError());
			}


		}

		$this->display();
	}
	//登录页面
	public function index ()
	{
		if(IS_POST){
			if($this->db->login()){
				$this->success('登录成功',U('Index/index'),'success');die;
			}else{
				$this->error($this->db->getError());
			}
		}
		$this->display( 'login' );
	}
	//验证码
	public function code(){
		$Verify =new \Think\Verify();
		$Verify->fontSize = 30;
		$Verify->length   = 2;
		$Verify->useNoise = false;
		$Verify->entry();
	}

}